/*
* $Id: ApiaryMidlet.java 277 2011-03-02 00:42:20Z volok-aleksej@yandex.ru $
*
* Copyright 2008-2011 by Volokitin Alexey
* All rights reserved
*
*/
package apiary;

import javax.microedition.midlet.MIDlet;

import apiary.ui.BackScreen;
import apiary.ui.LaunchForm;
import apiary.ui.UIXmlManager;

/**
 * Midlet application
 * @author lexus
 */
public class ApiaryMidlet extends MIDlet
{
    boolean isRunning;
    /**
     * Constructor
     */
    public ApiaryMidlet(){
        Apiary apiary = new Apiary(this);
        isRunning = false;
    }
    
    /**
     * MIDlet shutdown
     * @param destroy destroy or not
     */
    public void destroyApp(boolean destroy){
       //notifyDestroyed();
    }
    /**
     * MIDlet stops
     */
    public void pauseApp(){
    }
    /**
     * MIDlet starts or resumes if has been stopped
     */
    public void startApp(){
        if(!isRunning) {
            LaunchForm launch = new LaunchForm(getAppProperty("MIDlet-Icon"));
            Apiary.getInstance().Display(launch);
            UIXmlManager uiManager = new UIXmlManager();
            Apiary.getInstance().Display(uiManager.getFirstForm());
            isRunning = true;
        } else {
            BackScreen curDisplay = (BackScreen) Apiary.getInstance().getDisplay();
            Apiary.getInstance().Display(curDisplay);
        }
    }
}